home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / UTILITY / FDATE68A.ARJ / FILEDATE.BAT < prev    next >
DOS Batch File  |  1992-07-30  |  3KB  |  83 lines

  1. @echo off
  2. if (%1)==(SUBROUTINE1) goto %1
  3. cls
  4. goto EndDoc
  5. ----------------------------------------------------------------------
  6. This demo batch file shows how to use /If (input format = file) and
  7. /Ftcomp (function = time compare) to list files that are younger than,
  8. or at least as old as, %numdays%.  The basic logic in SUBROUTINE1 could
  9. be customized to do some more useful work, rather than just listing the
  10. filename.
  11.  
  12. If environment variable RAMDISK is set before running this batch
  13. file, then it will use the RAM disk and run a bit faster.
  14. ----------------------------------------------------------------------
  15. :EndDoc
  16.  
  17. rem set the number of days in the past that will be our cutoff point
  18. SET NUMDAYS=3
  19.  
  20. rem save today's date, so we can restore it later
  21. fdate /Ff /Omm-dd-yy /P"@set today=">%RAMDISK%JUNKTEMP.BAT
  22. call %RAMDISK%JUNKTEMP.BAT
  23.  
  24. rem determine the date %numdays% in the past
  25. fdate /Fsub /N%numdays%  /Omm-dd-yy /P"@set pastdate=">%RAMDISK%JUNKTEMP.BAT
  26. call %RAMDISK%JUNKTEMP.BAT
  27. del %RAMDISK%JUNKTEMP.BAT>nul
  28.  
  29. rem set current system date to %pastdate%
  30. DATE %pastdate%
  31.  
  32. rem create a file (whose creation date will be %pastdate%) to test against
  33. echo File created to bear creation date: %pastdate%> %RAMDISK%DATETEST.TMP
  34.  
  35. rem set current system date back to %today%
  36. DATE %today%
  37.  
  38.  
  39. echo ------------------------------------------------------------------
  40. Fdate /Fsub /N%numdays% /Ofull /P"FILES CREATED LESS THAN %numdays% DAYS AGO (AFTER " /S")"
  41. echo ------------------------------------------------------------------
  42. rem call a subroutine to list all of the files in this directory
  43. rem whose file date is greater than (after) %pastdate%
  44. rem ------------------------------------------------------------------
  45. for %%v in (*.*) do  CALL %0 SUBROUTINE1 %%v
  46. echo ------------------------------------------------------------------
  47. echo END: FILES CREATED LESS THAN %numdays% DAYS AGO
  48. echo ------------------------------------------------------------------
  49. PAUSE
  50.  
  51. CLS
  52. echo ------------------------------------------------------------------
  53. Fdate /Fsub /N%numdays% /Ofull /P"FILES CREATED AT LEAST %numdays% DAYS AGO (BEFORE " /S")"
  54. echo ------------------------------------------------------------------
  55. rem call a subroutine to list all of the files in this directory
  56. rem whose file date is less than or equal (earlier than) %pastdate%
  57. rem ------------------------------------------------------------------
  58. for %%v in (*.*) do  CALL %0 SUBROUTINE1 %%v  NOT
  59. echo ------------------------------------------------------------------
  60. echo END: FILES CREATED AT LEAST %numdays% DAYS AGO
  61. echo ------------------------------------------------------------------
  62. PAUSE
  63.  
  64. rem Delete these environment variables.  We don't need them any more.
  65. set numdays=
  66. set today=
  67. set pastdate=
  68. set tcomp=
  69. del %RAMDISK%JUNKTEMP.BAT>nul
  70.  
  71. goto endit
  72.  
  73.  
  74.  
  75. :SUBROUTINE1
  76. shift
  77. Fdate /Ftcomp /If /A%1 /B%RAMDISK%DATETEST.tmp /P"@set Tcomp=">%RAMDISK%JUNKTEMP.BAT
  78. CALL %RAMDISK%JUNKTEMP.BAT
  79. if %2 (%Tcomp%)==(GT) Fdate /Ff /If /A%1 /P"%1 created at " /Ofull
  80. rem fall through to endit
  81.  
  82. :endit
  83.